|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnegotiator.distributedtournament.DBController
public class DBController
Creates a DBControler. The DBController is used to manage the communication with the database in case a distributed tournament is ran. In this implementation, it is assumed that we are communicating with a busy webserver. Therefore, each time a group of operations has been performed, the connection is closed.
| Method Summary | |
|---|---|
java.lang.Object |
clone()
|
static byte[] |
compressBytes(java.lang.String data)
Compresses the data to be stored in the database. |
static boolean |
connect(java.lang.String url,
java.lang.String username,
java.lang.String password)
Connect to the database. |
void |
createJob(java.lang.String sessionName,
negotiator.tournament.Tournament t)
Creates a job by storing the tournament in the database, and splitting all sessions into smaller groups. |
boolean |
existsSessionName(java.lang.String sessionName)
Returns if a sessionname exists. |
static java.lang.String |
extractBytes(byte[] input)
Decompress a compressed string. |
static java.lang.String |
getDistributedTutorial()
|
static DBController |
getInstance()
|
Job |
getJob(int jobID,
java.util.ArrayList<negotiator.protocol.Protocol> sessions)
Gets a group of sessions to run. |
int |
getJobID(java.lang.String sessionname)
Returns the last issued job with the given session name. |
int |
getMatchesPerSession(int jobID)
Returns the amount of matches per session. |
int |
getRunningSessions(int jobID)
Get the amount of jobs which are currently executed by other instances of Genius or need to be processed. |
negotiator.tournament.Tournament |
getTournament(int jobID)
Given the jobID of the tournament, the tournament is requested from the database and stored as a Tournament object. |
static boolean |
reconnect()
Reconnect to the database. |
void |
reconstructLog(int jobID)
Reconstructs the full log of outcomes by gluing all separate outcomes of the job together. |
void |
resetJobs(int jobID)
Resets all sessions which were busy. |
void |
storeResult(int sessionID,
java.lang.String outcome)
Store the result of the group of sessions in the DB. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static DBController getInstance()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException
public static boolean connect(java.lang.String url,
java.lang.String username,
java.lang.String password)
url - with port (also supports properties: http://dev.mysql.com/doc/refman/5.0/en/connector-j-reference-configuration-properties.html)username - of the database accountpassword - of the database account
public static boolean reconnect()
public void createJob(java.lang.String sessionName,
negotiator.tournament.Tournament t)
sessionName - name of the session given to the tournamentt - tournament from which the jobs are derived.public int getJobID(java.lang.String sessionname)
sessionname - name of the session.
public negotiator.tournament.Tournament getTournament(int jobID)
jobID - of the tournament to be retrieved
public Job getJob(int jobID,
java.util.ArrayList<negotiator.protocol.Protocol> sessions)
jobID - id of the main job.sessions - array of all jobs of the tournament.
public void storeResult(int sessionID,
java.lang.String outcome)
sessionID - ID of the groupoutcome - outcome for the grouppublic int getRunningSessions(int jobID)
jobID - ID of the high-level job
public boolean existsSessionName(java.lang.String sessionName)
sessionName - name of the tournament.
public void resetJobs(int jobID)
jobID - ID of the high-level jobpublic void reconstructLog(int jobID)
jobID - ID of the jobpublic int getMatchesPerSession(int jobID)
jobID - ID of the high-level job
public static java.lang.String getDistributedTutorial()
public static byte[] compressBytes(java.lang.String data)
throws java.io.UnsupportedEncodingException,
java.io.IOException
data - to be compressed.
java.io.UnsupportedEncodingException - if UTF-8 encoding is not supported.
java.io.IOException - if there is a problem reading the string.
public static java.lang.String extractBytes(byte[] input)
throws java.io.UnsupportedEncodingException,
java.io.IOException,
java.util.zip.DataFormatException
input - compressed byte array which needs to be decompressed.
java.io.UnsupportedEncodingException - if UTF-8 encoding is not supported.
java.io.IOException - if there is a problem reading the byte array.
java.util.zip.DataFormatException - should not happen.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||